﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Net;
using System.Text.RegularExpressions;
using System.Web.Security;

namespace KorleBu
{
    public class Presentation
    {
        public Presentation()
        {

        }

        //////////Login Methods//////////
        // Login
        // GetHint
        // GetSaltByUserName
        // IsValidSession
        // Logout
        /////////////////////////////////
        #region Login Methods

        /// <summary>
        /// Login Method
        /// Written by Bryan Nixon
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="ipAddress"></param>
        /// <returns>DataSet</returns>
        public DataSet Login(string userName, string password, string ipAddress)
        {

            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.Login(userName, password, ipAddress);
            }
            catch (Exception ex)
            {
                ds = SetError("Error logging in", ex);
            }
            return ds;
        }

        /// <summary>
        /// Get Hint gets the hint based on the username
        /// Written by Bryan Nixon 
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>DataSet containing a string</returns>
        public DataSet GetHint(string userName)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                // validate data from login page
                if (!isValidUserName(userName))
                {
                    ds.Tables.Add();
                    ds.Tables[0].Columns.Add();
                    ds.Tables[0].Rows.Add();
                    ds.Tables[0].Rows[0][0] = "Invalid UserName";
                }
                else
                {
                    ds = dt.GetHint(userName);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error getHint Method", ex);
            }
            return ds;
        }

        /// <summary>
        /// Method gets a user's password salt by their user name.
        /// Written by Aaron Mauchley
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public DataSet GetSaltByUserName(string userName)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetSaltByUserName(userName);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting salt", ex);
            }
            return ds;
        }

        /// <summary>
        /// Checkes to see if the session is valid
        /// Written by Bryan Nixon
        /// </summary>
        /// <param name="sessionID"></param>
        /// <returns>DataSet</returns>
        public DataSet IsValidSession(string sessionID)
        {
            // Refresh Session...

            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                // validate data from login page
                //isValIPAddress(ipAddress) -- Used in example
                if (string.IsNullOrEmpty(sessionID))
                {
                    ds.Tables.Add();
                    ds.Tables[0].Columns.Add();
                    ds.Tables[0].Rows.Add();
                    ds.Tables[0].Rows[0][0] = "Insufficient Permissions";
                }
                else
                {
                    ds = dt.IsValidSession(sessionID);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error checking IP", ex);
            }
            return ds;
        }

        /// <summary>
        /// Logs the user out of the program
        /// Written by Bryan Nixon
        /// </summary>
        /// <param name="sessionID"></param>
        /// <returns>DataSet</returns>
        public DataSet Logout(string sessionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                // validate data from login page
                ds = IsValidSession(sessionID);
                if (ds.Tables[0].Rows[0][0].ToString() == "") // If no errors
                {
                    //get data from DataTier
                    ds.Clear();
                    ds = dt.Logout(sessionID);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error logging out", ex);
            }
            return ds;
        }


        #endregion

        //////////Item Methods//////////
        // AddItem
        // ModifyItem
        // AddCategory
        // ModifyCategory
        // GetItems
        // GetUnits
        // GetCategory
        // GetItemsByStoreUnit   
        // GetItemByName
        // GetItemByNameByStore
        // GetItemByCategory
        // GetItemByCategoryByStore  
        // AdjustItemQuantity
        // GetItemAdjustmentReasons
        // CreateItemAdjustmentReason
        // AllocateItem
        // GetAllItemsForStoreID
        /////////////////////////////////
        #region Item Methods
        public DataSet AllocateNewItem(string itemName, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AllocateNewItem(itemName, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting items", ex);
            }
            return ds;
        }
        /// <summary>
        /// Adds a new Item to the database.
        /// Sean Christensen
        /// Modified by Bryan Nixon 6-7-2012
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet AddItem(string itemName, int categoryID, int unitID, double vendorCost, double markupPercent, int emergencyQuantity, int minStockQty, int vendorID, int statusID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            ds.Tables.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Rows.Add();
            try
            {
                //Do validation
                if (!isValidItemCategory(itemName))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Item Name";
                }
                else if (double.IsNaN(vendorCost))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Cost";
                }
                else if (double.IsNaN(markupPercent))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Markup Percent";
                }
                else
                {
                    // Get the store id based on the category
                    ds = dt.GetCategory();
                    int storeID = 0;
                    foreach (DataRow row in ds.Tables[1].Rows)
                    {
                        String catId = row["ItemCategoryID"].ToString();
                        int id = Convert.ToInt32(catId);
                        if (categoryID == id) { storeID = Convert.ToInt32(row["StoreID"]); break; }
                    }

                    //this is the format the database likes, IE, 15% = 1.15 to the database.
                    markupPercent = markupPercent / 100 + 1;

                    ds = dt.AddItem(itemName, categoryID, unitID, vendorCost, markupPercent, emergencyQuantity, minStockQty, vendorID, storeID, statusID);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding item", ex);
            }
            return ds;
        }

        /// <summary>
        /// 11-24-12 Adam Venezia; When modifying an item, we need to fill in the existing data to a modify template.
        /// </summary>
        /// <param name="itemID">Item ID to query the database against.</param>
        /// <returns>DataSet containing Error table[0] and Data table[1].</returns>
        public DataSet GetModifyInfoByID(int itemID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();

            try
            {
                ds = dt.GetModifyInfoByID(itemID);
            }
            catch (Exception ex)
            {
                ds = SetError(null, ex);
            }

            return ds;
        }

        /// <summary>
        /// 11-24-12 Adam Venezia; Committing modify Item.
        /// </summary>
        /// <returns>DataSet table[0] with errors, table[1] with 1 = completed, 0 = not completed</returns>
        public DataSet ModifyItem(int itemID, string itemName, int unitID, double vendorCost,
            int itemCategoryID, int emergencyQty, double markupPercent, int vendorID, int statusID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            ds.Tables.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Rows.Add();
            try
            {
                //Do validation
                if (!isValidItemCategory(itemName))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Item Name";
                }
                else if (double.IsNaN(vendorCost))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Cost";
                }
                else if (double.IsNaN(markupPercent))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Markup Percent";
                }
                else
                {
                    // Get the store id based on the category
                    ds = dt.GetCategory();
                    int storeID = 0;
                    foreach (DataRow row in ds.Tables[1].Rows)
                    {
                        String catId = row["ItemCategoryID"].ToString();
                        int id = Convert.ToInt32(catId);
                        if (itemCategoryID == id) { storeID = Convert.ToInt32(row["StoreID"]); break; }
                    }

                    //this is the format the database likes, IE, 15% = 1.15 to the database.
                    markupPercent = markupPercent / 100 + 1;

                    ds = dt.ModifyItem(itemID, itemName, unitID, vendorCost, itemCategoryID,
                        emergencyQty, storeID, markupPercent, vendorID, statusID);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying item", ex);
            }
            return ds;
        }

        /// <summary>
        /// Adds a new category.
        /// Sean Christensen
        /// Modified by Bryan Nixon 6-7-2012
        /// </summary>
        /// <param name="categoryName"></param>
        /// <returns>DataSet</returns>
        public DataSet AddCategory(string categoryName, string storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            ds.Tables.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Rows.Add();
            try
            {
                //Do validation
                if (!isValidItemCategory(categoryName))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Category Name";
                }
                else
                {
                    ds = dt.AddCategory(categoryName, storeID);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding category", ex);
            }
            return ds;
        }

        /// <summary>
        /// Modifies a category name.
        /// Sean Christensen
        /// Modified by Bryan Nixon 6-7-2012
        /// </summary>
        /// <param name="itemCategoryID"></param>
        /// <param name="categoryName"></param>
        /// <returns>DataSet</returns>
        public DataSet ModifyCategory(int itemCategoryID, string categoryName, string storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            ds.Tables.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Rows.Add();
            try
            {
                //Do validation
                if (!isValidItemCategory(categoryName))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Category Name";
                }
                else
                    ds = dt.ModifyCategory(itemCategoryID, categoryName, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying category", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets all items in the database
        /// By Sean Christensen
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetItems()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetItems();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting items", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets all used units i.e. inch, feet, pound, kilogram.
        /// By Sean Christensen
        /// Modified by Bryan Nixon 6-7-2012
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetUnits()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetUnits();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting units", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets a full list of categories.
        /// By Sean Christensen
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetCategory()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetCategory();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting category", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="storeID"></param>
        /// <param name="subUnitID"></param>
        /// <returns></returns>
        public DataSet GetItemsByStoreUnit(int storeID, int subUnitID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetItemsByStoreUnitID(storeID, subUnitID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting items by store unit", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets all information specific to a single item.
        /// By Sean Christensen
        /// Modified by Bryan Nixon 6-7-2012
        /// </summary>
        /// <param name="itemName"></param>
        /// <returns>DataSet</returns>
        public DataSet GetItemByName(string itemName)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            ds.Tables.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Rows.Add();
            try
            {
                //Do validation
                if (!isValidItemCategory(itemName))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Item Name";
                }
                else
                {
                    ds = dt.GetItemByName(itemName);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting item", ex);
            }

            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="itemName"></param>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet GetItemByNameByStore(string itemName, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetItemByNameByStore(itemName, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions not closed", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets a list of all items in a specific category.
        /// By Sean Christensen
        /// Modified by Bryan Nixon 6-7-2012
        /// </summary>
        /// <param name="categoryName"></param>
        /// <returns>DataSet</returns>
        public DataSet GetItemByCategory(int categoryID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetItemByCategory(categoryID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting category", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="itemCategoryID"></param>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet GetItemByCategoryByStore(int itemCategoryID, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetItemByCategoryByStore(itemCategoryID, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions not closed", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="itemID"></param>
        /// <param name="quantity"></param>
        /// <param name="positiveNumber"></param>
        /// <returns></returns>
        public DataSet AdjustItemQuantity(int itemID, int quantity, int reasonID, int userID, int storeID, int subUnitID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AdjustItemQuantity(itemID, quantity, reasonID, userID, storeID, subUnitID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error adjusting item quantity", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet GetItemAdjustmentReasons()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetItemAdjustmentReasons();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting reason list for changing item quantity", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet CreateItemAdjustmentReason(string adjReason)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CreateItemAdjustmentReason(adjReason);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting reason list for changing item quantity", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Jason Vance - 27 Nov 2012
        /// </summary>
        /// <returns></returns>
        public DataSet ModifyItemAdjustmentReason(int adjID, string adjReason)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ModifyItemAdjustmentReason(adjID, adjReason);
            }
            catch (Exception ex)
            {
                ds = SetError("Error while changing the adjustment reason", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="itemID"></param>
        /// <returns>DataSet</returns>
        public DataSet AllocateItem(int storeID, int emergencyQuantity, int itemID, int itemQuantity)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AllocateItem(storeID, emergencyQuantity, itemID, itemQuantity);
            }
            catch (Exception ex)
            {
                ds = SetError("Error allocating item", ex);
            }
            return ds;
        }


        public DataSet GetAllItemsForStoreID(int storeID, int subUnitID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAllItemsForStoreID(storeID, subUnitID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting items", ex);
            }
            return ds;
        }

        #endregion

        //////////User Methods//////////
        // AddUser
        // ModifyUser
        // UpdatePassword
        // GetUserByID
        // GetUserByName
        // GetAllUsers
        // GetUsersByRole
        // GetUsersByStatusID
        /////////////////////////////////
        #region User Methods

        /// <summary>
        /// Method used to create a new User
        /// Written by Bryan Nixon
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="passwordHint"></param>
        /// <param name="isAdmin"></param>
        /// <param name="isGeneralManager"></param>
        /// <param name="isStoreManager"></param>
        /// <param name="isStoreKeeper"></param>
        /// <param name="isSubUnitClerk"></param>
        /// <param name="isCEO"></param>
        /// <param name="isAccounting"></param>
        /// <param name="isProcurement"></param>
        /// <returns>DataSet</returns>
        public DataSet AddUser(string firstName, string lastName, string userName, string password, string passwordHint, int storeID,
            bool isAdmin, bool isGeneralManager, bool isStoreManager, bool isStoreKeeper, bool isSubUnitClerk,
            bool isCEO, bool isAccounting, bool isProcurement, string salt)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            ds.Tables.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Rows.Add();
            try
            {
                //Do validation
                if (!isValidFirstName(firstName))
                {
                    ds.Tables[0].Rows[0][0] = "Please Enter your First Name";
                }
                else if (!isValidSurName(lastName))
                {
                    ds.Tables[0].Rows[0][0] = "Please Enter your Surname";
                }
                else if (!isValidUserName(userName))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid UserName";
                }
                else if (!isValidPW(password))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Password";
                }
                else if (!isValidHint(passwordHint))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Hint";
                }
                else if (!isAdmin & !isGeneralManager & !isStoreManager & !isStoreKeeper & !isSubUnitClerk & !isCEO & !isAccounting & !isProcurement)
                {
                    ds.Tables[0].Rows[0][0] = "Please Select a Role";
                }
                else if (!isValidRoleSelection(isGeneralManager, isStoreManager, isSubUnitClerk, isCEO))
                {
                    ds.Tables[0].Rows[0][0] = "Cannot have more than one specific role type";
                }
                else
                {
                    password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");
                    ds = dt.AddUser(firstName, lastName, userName, password, passwordHint, storeID, isAdmin,
                         isCEO, isGeneralManager, isStoreManager, isStoreManager, isSubUnitClerk, isAccounting, isProcurement, salt);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error creating user", ex);
            }
            return ds;
        }

        /// <summary>
        /// Method used to modify an existing User
        /// Written by Bryan Nixon
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="userName"></param>
        /// <param name="passwordHint"></param>
        /// <param name="statusID"></param>
        /// <param name="isAdmin"></param>
        /// <param name="isGeneralManager"></param>
        /// <param name="isStoreManager"></param>
        /// <param name="isStoreKeeper"></param>
        /// <param name="isSubUnitClerk"></param>
        /// <param name="isCEO"></param>
        /// <param name="isAccounting"></param>
        /// <param name="isProcurement"></param>
        /// <returns>DataSet</returns>
        public DataSet ModifyUser(int userID, string firstName, string lastName, string userName, string passwordHint,
            int statusID, int storeID, bool isAdmin, bool isGeneralManager, bool isStoreManager, bool isStoreKeeper,
            bool isSubUnitClerk, bool isCEO, bool isAccounting, bool isProcurement)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            ds.Tables.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Rows.Add();
            try
            {
                //Do validation
                if (!isValidFirstName(firstName))
                {
                    ds.Tables[0].Rows[0][0] = "Please Enter your First Name";
                }
                else if (!isValidSurName(lastName))
                {
                    ds.Tables[0].Rows[0][0] = "Please Enter your Sur Name";
                }
                else if (!isValidUserName(userName))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid UserName";
                }
                else if (!isValidHint(passwordHint))
                {
                    ds.Tables[0].Rows[0][0] = "Invalid Hint";
                }
                else if (!isAdmin & !isGeneralManager & !isStoreManager & !isStoreKeeper & !isSubUnitClerk & !isCEO & !isAccounting & !isProcurement)
                {
                    ds.Tables[0].Rows[0][0] = "Please Select a Role";
                }
                else if (!isValidRoleSelection(isGeneralManager, isStoreManager, isSubUnitClerk, isCEO))
                {
                    ds.Tables[0].Rows[0][0] = "Cannot have more than one specific role type";
                }
                else
                {
                    ds = dt.ModifyUser(userID, firstName, lastName, userName, passwordHint, statusID, storeID, isAdmin,
                       isCEO, isGeneralManager, isStoreManager, isStoreManager, isSubUnitClerk, isAccounting, isProcurement);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying user", ex);
            }
            return ds;
        }

        /// <summary>
        /// Method used to change a user's password
        /// Written by Bryan Nixon 
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="oldPassword"></param>
        /// <param name="newPassword"></param>
        /// <returns>DataSet</returns>
        public DataSet UpdatePassword(int userID, string oldPassword, string newPassword, string salt)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                if (!isValidPW(newPassword))
                {
                    DataTable table = new DataTable();
                    table.Columns.Add("ErrorMessage");
                    DataRow dr = table.NewRow();
                    dr[0] = "Invalid Password";
                    table.Rows.Add(dr);
                    ds.Tables.Add(table);
                }
                else
                {
                    newPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword, "SHA1");
                    ds = dt.UpdatePassword(userID, oldPassword, newPassword, salt);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error updating password", ex);
            }
            return ds;
        }

        /// <summary>
        /// Method gets a user's info by their ID
        /// Written by Bryan Nixon 
        /// </summary>
        /// <param name="userID"></param>
        /// <returns>DataSet</returns>
        public DataSet GetUserByID(int userID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetUserByID(userID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting user", ex);
            }
            return ds;
        }

        /// <summary>
        /// Method gets a user's info by their first & last name
        /// Written by Bryan Nixon 
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <returns></returns>
        public DataSet GetUserByName(string firstName, string lastName)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            ds.Tables.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Rows.Add();
            try
            {
                //Do validation
                if (!isValidFirstName(firstName))
                {
                    ds.Tables[0].Rows[0][0] = "Please Enter your First Name";
                }
                else if (!isValidSurName(lastName))
                {
                    ds.Tables[0].Rows[0][0] = "Please Enter your Sir Name";
                }
                else
                {
                    ds = dt.GetUserByName(firstName, lastName);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting user", ex);
            }

            return ds;
        }

        /// <summary>
        /// This method gets a list of all users.
        /// By Sean Christensen
        /// </summary>
        /// <returns>Parse First and Last into one name (fullName)</returns>
        public DataSet GetAllUsers()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAllUsers();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting users", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets a list of users with a specific role
        /// By Sean Christensen
        /// </summary>
        /// <param name="isAdmin"></param>
        /// <param name="isGeneralManager"></param>
        /// <param name="isStoreManager"></param>
        /// <param name="isStoreKeeper"></param>
        /// <param name="isSubUnitClerk"></param>
        /// <param name="isCEO"></param>
        /// <param name="isAccounting"></param>
        /// <param name="isProcurement"></param>
        /// <returns>DataSet</returns>
        public DataSet GetUsersByRole(bool isAdmin, bool isGeneralManager, bool isStoreManager, bool isStoreKeeper,
            bool isSubUnitClerk, bool isCEO, bool isAccounting, bool isProcurement)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetUsersByRole(isAdmin, isGeneralManager, isStoreManager, isStoreKeeper,
                    isSubUnitClerk, isCEO, isAccounting, isProcurement);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting users", ex);
            }
            return ds;
        }

        /// <summary>
        /// GetUsersByStatusId
        /// Gets all users by statusID (Inactive or Active ... etc)
        /// Created by Bryan Nixon
        /// </summary>
        /// <param name="statusID"></param>
        /// <returns>UserID and First and Last Name</returns>
        public DataSet GetUsersByStatusID(int statusID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetUsersByStatusID(statusID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting users", ex);
            }
            return ds;
        }

        #endregion

        //////////Requests Methods//////////
        // MarkRequestItemPartialFill
        // CreateRequest
        // CheckOpenRequest
        // AddItemToRequest
        // ChangeRequestDescription
        // SubmitRequest
        // GetPendingRequests
        // GetRequestItemsByRequestID
        // GetRequestsByStoreID
        // GetRequestByCreatingStatus
        // DeleteRequestItem
        // CancelRequest
        // ItemsandQuantity
        // FillRequestItem
        // GetRequestReady
        // GetRequestReadyItems
        // ModifyRequest
        // UpadteEmergencyQuantity
        // MarkRequestStatusByStatusID
        /////////////////////////////////
        #region Requests Methods

        public DataSet MarkRequestItemPartialFill(int requestID, int itemID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.MarkRequestItemPartialFill(requestID, itemID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error partially filling request", ex);
            }
            return ds;
        }
        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="StoreID"></param>
        /// <param name="requestDescription"></param>
        /// <returns></returns>
        public DataSet MarkRequestItemClosed(int requestID, int itemID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.MarkRequestItemClosed(requestID, itemID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error creating request", ex);
            }
            return ds;
        }
        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="StoreID"></param>
        /// <param name="requestDescription"></param>
        /// <returns></returns>
        public DataSet CreateRequest(int StoreID, string requestDescription)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CreateRequest(StoreID, requestDescription);
            }
            catch (Exception ex)
            {
                ds = SetError("Error creating request", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="StoreID"></param>
        /// <returns></returns>
        public DataSet CheckOpenRequest(int StoreID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CheckOpenRequest(StoreID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error checking open request", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="requestID"></param>
        /// <param name="itemID"></param>
        /// <param name="qtyRequested"></param>
        /// <returns></returns>
        public DataSet AddItemToRequest(int requestID, int itemID, int qtyRequested)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AddItemToRequest(requestID, itemID, qtyRequested);
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding item to request", ex);
            }
            return ds;
        }

        public DataSet ChangeRequestDescription(int requestID, string description)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ChangeRequestDescription(requestID, description);
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding item to request", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="requestID"></param>
        /// <returns></returns>
        public DataSet SubmitRequest(int requestID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.SubmitRequest(requestID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error submitting request", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetPendingRequests(int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetPendingRequests(storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting pending requests", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="requestID"></param>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet GetRequestItemsByRequestID(int requestID, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequestItemsByRequestID(requestID, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting request items", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet GetRequestsByStoreID(int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequestsByStoreID(storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting request", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet GetRequestByCreatingStatus(int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                //ds = dt.GetRequestByCreatingStatus(storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting request", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="RequestID"></param>
        /// <param name="ItemID"></param>
        /// <returns></returns>
        public DataSet DeleteRequestItem(int RequestID, int ItemID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.DeleteRequestItem(RequestID, ItemID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error deleting item on request", ex);
            }
            return ds;
        }

        public DataSet DeleteRequest(int RequestID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.DeleteRequest(RequestID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error deleting item on request", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="requestID"></param>
        /// <returns></returns>
        public DataSet ItemsandQuantity(int requestID, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ItemsandQuantity(requestID, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting items and quantity", ex);
            }
            return ds;
        }

        /// <summary>
        /// Benjamin Strickler
        /// </summary>
        /// <param name="requestID"></param>
        /// <param name="itemID"></param>
        /// <param name="QtyReceived"></param>
        /// <returns></returns>
        public DataSet FillRequestItem(int requestID, int itemID, int QtyReceived, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.FillRequestItem(requestID, itemID, QtyReceived, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error filling request item", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet GetRequestReady(int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequestReady(storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting ready request", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requestID"></param>
        /// <returns></returns>
        public DataSet GetRequestReadyItems(int requestID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequestReadyItems(requestID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting ready request items", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requestID"></param>
        /// <param name="itemID"></param>
        /// <param name="qty"></param>
        /// <returns></returns>
        public DataSet ModifyRequest(int requestID, int itemID, int qty)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ModifyRequest(requestID, itemID, qty);
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying request", ex);
            }
            return ds;
        }

        /// <summary>
        /// Bryan Nixon
        /// </summary>
        /// <param name="requestID"></param>
        /// <param name="statusID"></param>
        /// <returns></returns>
        public DataSet MarkRequestStatusByStatusID(int requestID, int statusID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.MarkRequestStatusByStatusID(requestID, statusID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error updating request", ex);
            }
            return ds;
        }

        /// <summary>
        /// Bryan Nixon
        /// </summary>
        /// <param name="requestID"></param>
        /// <returns></returns>
        public DataSet UpdateRequestStatus(int requestID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.UpdateRequestStatus(requestID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error updating request", ex);
            }
            return ds;
        }

        #endregion

        //////////Store Requisition Methods//////////
        // GetRequisitionsByGMStatus
        // CheckSignature
        // GetRequisitionsByPendingStatus
        // GetRequisitionNotClosed
        // GetRequisitionsByCEOStatus
        // GetRequisitionsByOrderedStatus
        // GetRequisitionItemsByRequisitionID
        // AddRequisition
        // SubmitRequisition
        // CheckItemInStock????????????????????????
        // IsRequisition???????????????????????????
        // RejectRequisition
        // AcceptRejectRequisitionItem
        // ModifyRequisition
        // AcceptRequisition
        // CheckOpenRequisition????????????????????
        // DeleteRequisitionItem
        // ReallocateItem
        // ChangeRequisitionItemQty
        // MarkItemReady 
        // GetStoreUnitItemQty 
        // GetRequisitionsNotClosedByStore
        // GetRequestItemsByRequestByStore
        // AddItemToRequisition
        // ChangeRequisitionDescription
        /////////////////////////////////
        #region Store Requisition Methods

         
        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet CheckToCloseRequisition(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CheckToCloseRequisition(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisition by GM", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetRequisitionsByGMStatus()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequisitionsByGMStatus();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisition by GM", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <param name="RequisitionID"></param>
        /// <returns>DataSet</returns>
        public DataSet CheckSignature(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CheckSignature(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error checking signature", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetRequisitionsByPendingStatus()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequisitionsByPendingStatus();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting pending requisitions", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetRequisitionNotClosed()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequisitionNotClosed();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions not closed", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetRequisitionsByCEOStatus()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequisitionsByCEOStatus();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions by CEO", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <param name="storeID"></param>
        /// <returns>DataSet</returns>
        public DataSet GetRequisitionsByOrderedStatus(int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequisitionsByOrderedStatus(storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <param name="getDenied"></param>
        /// <returns>DataSet</returns>
        public DataSet GetRequisitionItemsByRequisitionID(int requisitionID, bool getDenied)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequisitionItemsByRequisitionID(requisitionID, getDenied);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisition items", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <param name="subUnit"></param>
        /// <param name="userName"></param>
        /// <returns>DataSet</returns>
        public DataSet AddRequisition(int storeID, string requisitionName)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AddRequisition(storeID, requisitionName);
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding requisition", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <param name="userName"></param>
        /// <param name="comment"></param>
        /// <returns>DataSet</returns>
        public DataSet SubmitRequisition(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.SubmitRequisition(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error submitting requisition", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="itemID"></param>
        /// <param name="subUnit"></param>
        /// <param name="storeID"></param>
        /// <returns>DataSet</returns>
        public DataSet CheckItemInStock(int itemID, string subUnit, string storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                //ds = dt.CheckItemInStock(itemID, subUnit, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error checking item in stock", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <returns>DataSet</returns>
        public DataSet IsRequisition(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                //ds = dt.IsRequisition(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error validating requisition ID", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <returns>DataSet</returns>
        public DataSet RejectRequisition(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.RejectRequisition(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error rejecting requisition", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <param name="RequisitionID"></param>
        /// <param name="ItemID"></param>
        /// <param name="isDenied"></param>
        /// <returns>DataSet</returns>
        public DataSet AcceptRejectRequisitionItem(int requisitionID, int itemID, bool isDenied)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AcceptRejectRequisitionItem(requisitionID, itemID, isDenied);
            }
            catch (Exception ex)
            {
                ds = SetError("Error accepting or rejecting requisition item", ex);
            }
            return ds;
        }

        
        public DataSet AddCommentToRequsition(int requisitionID, String comments)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AddCommentToRequsition(requisitionID, comments);
            }
            catch (Exception ex)
            {
                ds = SetError("Error accepting or rejecting requisition item", ex);
            }
            return ds;
        }


        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <returns>DataSet</returns>
        public DataSet ModifyRequisition(int requisitionID, int storeID, int itemID, int qty)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ModifyRequisition(requisitionID, storeID, itemID, qty);
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying requisition", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <returns>DataSet</returns>
        public DataSet AcceptRequisition(int requisitionID, int user, bool gm, bool ceo)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AcceptRequisition(requisitionID, user, gm, ceo);
            }
            catch (Exception ex)
            {
                ds = SetError("Error accepting requisition", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Benjamin Strickler
        /// </summary>
        /// <param name="StoreID"></param>
        /// <returns>DataSet</returns>
        public DataSet CheckOpenRequisition(int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CheckOpenRequisition(storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error checking open requisitions", ex);
            }
            return ds;
        }

        /// <summary>
        /// Deletes a specific item from the requisition
        /// By Sean Christensen
        /// </summary>
        /// <param name="StoreID"></param>
        /// <returns>DataSet</returns>
        public DataSet DeleteRequisitionItem(int requisitionID, int itemID, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.DeleteRequisitionItem(requisitionID, itemID, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error deleting requisition item", ex);
            }
            return ds;
        }

        /// <summary>
        /// reallocates an item from one subunit to another subunit
        /// By Sean Christensen
        /// </summary>
        /// <param name="itemID"></param>
        /// <param name="storeID"></param>
        /// <param name="subUnitFromID"></param>
        /// <param name="subUnitToID"></param>
        /// <param name="qty"></param>
        /// <returns>DataSet</returns>
        public DataSet ReallocateItem(int itemID, int storeID, int subUnitFromID, int subUnitToID, int qty)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ReallocateItem(itemID, storeID, subUnitFromID, subUnitToID, qty);
            }
            catch (Exception ex)
            {
                ds = SetError("Error reallocating item", ex);
            }
            return ds;
        }

        /// <summary>
        /// Changes an items quantity in a requisition
        /// By Sean Christensen
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <param name="itemID"></param>
        /// <param name="qty"></param>
        /// <returns>DataSet</returns>
        public DataSet ChangeRequisitionItemQty(int requisitionID, int itemID, int qty)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ChangeRequisitionItemQty(requisitionID, itemID, qty);
            }
            catch (Exception ex)
            {
                ds = SetError("Error changing requisition item quantity", ex);
            }
            return ds;
        }

        /// <summary>
        /// Marks an item ready for pickup
        /// By Sean Christensen
        /// </summary>
        /// <param name="satelliteStoreRequisitionID"></param>
        /// <param name="itemID"></param>
        /// <returns>DataSet</returns>
        public DataSet MarkItemReady(int satelliteStoreRequisitionID, int itemID, int allocated, int RequestItemID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.MarkItemReady(satelliteStoreRequisitionID, itemID, allocated, RequestItemID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error marking item as ready", ex);
            }
            return ds;
        }

        /// <summary>
        /// Marks an item ready for pickup
        /// By Sean Christensen
        /// </summary>
        /// <param name="satelliteStoreRequisitionID"></param>
        /// <param name="itemID"></param>
        /// <returns>DataSet</returns>
        public DataSet MarkItemOrdered(int satelliteStoreRequisitionID, int itemID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.MarkItemOrdered(satelliteStoreRequisitionID, itemID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error marking item as ready", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets an item quantity in a store unit
        /// By Sean Christensen
        /// </summary>
        /// <param name="storeID"></param>
        /// <param name="subUnitID"></param>
        /// <param name="itemID"></param>
        /// <returns>DataSet</returns>
        public DataSet GetStoreUnitItemQty(int storeID, int subUnitID, int itemID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetStoreUnitItemQty(storeID, subUnitID, itemID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error store unit item quantity", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets any requisitions that are not closed by a store
        /// By Sean Christensen
        /// </summary>
        /// <param name="storeID"></param>
        /// <returns>DataSet</returns>
        public DataSet GetRequisitionsNotClosedByStore(int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequisitionsNotClosedByStore(storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions not closed", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="requestID"></param>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet GetRequestItemsByRequestByStore(int requestID, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequestItemsByRequestByStore(requestID, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions not closed", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <param name="itemID"></param>
        /// <param name="requestedQty"></param>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet AddItemToRequisition(int requisitionID, int itemID, int requestedQty, int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AddItemToRequisition(requisitionID, itemID, requestedQty, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions not closed", ex);
            }
            return ds;
        }

        public DataSet ChangeRequisitionDescription(int requisitionID, string description)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ChangeRequisitionDescription(requisitionID, description);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions not closed", ex);
            }
            return ds;
        }

        public DataSet CancelRequisition(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CancelRequisition(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisitions not closed", ex);
            }
            return ds;
        }

        #endregion

        public DataSet UpdateEmergencyQuantity(int itemID, int qty)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.UpdateEmergencyQuantity(itemID, qty);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisition by GM", ex);
            }
            return ds;
        }

        public DataSet GetCategoryByStore(int StoreID)
        {

            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetCategoryByStore(StoreID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisition by GM", ex);
            }
            return ds;
        }

        public DataSet GetRequestItemsByRequestIDStoreManger(int requestID, int storeID)
        {

            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequestItemsByRequestIDStoreManger(requestID, storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisition by GM", ex);
            }
            return ds;
        }

        public DataSet SubmitOutside(int ORequisitionID, int OVendorID, String OrderNo)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.SubmitOutside(ORequisitionID, OVendorID, OrderNo);
            }
            catch (Exception ex)
            {
                ds = SetError("Error submitting outside requisition.", ex);
            }
            return ds;
        }

        public DataSet CheckOpenOutsideProcurement(int StoreID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CheckOpenOutsideProcurement(StoreID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting partially created outside requisition.", ex);
            }
            return ds;
        }

        public DataSet InsertOutsideProcureToInventory(int outsideID, String orderNo, int vendorID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.InsertOutsideProcureToInventory(outsideID, orderNo, vendorID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting partially created outside requisition.", ex);
            }
            return ds;
        }

        //////////Statuses Methods//////////
        // GetAvailableItemStatuses
        // GetAvailableUserStatuses
        // GetAvailableVendorStatuses
        // GetAvailableRequisitionStatuses
        // GetAvailableStoreStatuses
        // GetAvailableStoreTypeStatuses
        // GetAvailableSubUnitStatuses
        // GetAvailableStoreUnitStatuses
        // GetAvailableSatelliteStoreRequestStatuses
        /////////////////////////////////
        #region Statuses Methods

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet GetAvailableItemStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableItemStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting statuses", ex);
            }
            return ds;
        }

        /// <summary>
        /// Get different statuses for the users for drop down
        /// Created by Bryan Nixon
        /// </summary>
        public DataSet GetAvailableUserStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableUserStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting user status", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet GetAvailableVendorStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableVendorStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting vendor status", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet GetAvailableRequisitionStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableRequisitionStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting requisition status", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet GetAvailableStoreStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableStoreStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting store status", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet GetAvailableStoreTypeStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableStoreTypeStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting store type status", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet GetAvailableSubUnitStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableSubUnitStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting subunit status", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets all store unit statuses
        /// By Sean Christensen
        /// </summary>
        /// <returns>Data set - store statuses and IDs</returns>
        public DataSet GetAvailableStoreUnitStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableStoreUnitStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting store unit status", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetAvailableSatelliteStoreRequestStatuses()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAvailableSatelliteStoreRequestStatuses();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting request status", ex);
            }
            return ds;
        }

        #endregion

        //////////Store_Subunit Methods//////////
        // AddSubUnit
        // ModifySubUnit
        // AddStoreUnit
        // ModifyStoreUnit
        // AddStore
        // ModifyStore
        // GetStoreTypes
        // GetSubUnitByID
        // GetSubUnitByName
        // GetStoreByID
        // GetStoreByName
        // GetStoreUnitStatus
        // GetAllStores
        // GetActiveCentralStores
        // GetSubUnits
        // GetActiveSubUnits
        // GetStoreUnits
        // GetStoresByType
        /////////////////////////////////
        #region Store_Subunit

        /// <summary>
        /// 
        /// </summary>
        /// <param name="subUnitName"></param>
        /// <returns></returns>
        public DataSet AddSubUnit(string subUnitName)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AddSubUnit(subUnitName);
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding subunit", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="subUnitID"></param>
        /// <param name="subUnitName"></param>
        /// <param name="statusID"></param>
        /// <returns></returns>
        public DataSet ModifySubUnit(int subUnitID, string subUnitName, int statusID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ModifySubUnit(subUnitID, subUnitName, statusID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying subunit", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="storeID"></param>
        /// <param name="subUnitID"></param>
        /// <returns></returns>
        public DataSet AddStoreUnit(int storeID, int subUnitID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AddStoreUnit(storeID, subUnitID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding store unit", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="storeID"></param>
        /// <param name="subUnitID"></param>
        /// <param name="statusID"></param>
        /// <returns></returns>
        public DataSet ModifyStoreUnit(int storeID, int subUnitID, int statusID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ModifyStoreUnit(storeID, subUnitID, statusID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying store unit", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="storeName"></param>
        /// <param name="storeTypeID"></param>
        /// <returns></returns>
        public DataSet AddStore(string storeName, int storeTypeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.AddStore(storeName, storeTypeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding store", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="storeID"></param>
        /// <param name="storeName"></param>
        /// <param name="storeTypeID"></param>
        /// <returns></returns>
        public DataSet ModifyStore(int storeID, string storeName, int storeTypeID, int statusID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ModifyStore(storeID, storeName, storeTypeID, statusID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying store", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetStoreTypes()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetStoreTypes();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting store types", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="subUnitID"></param>
        /// <returns></returns>
        public DataSet GetSubUnitByID(int subUnitID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetSubUnitByID(subUnitID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting subunit", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="subUnitName"></param>
        /// <returns></returns>
        public DataSet GetSubUnitByName(string subUnitName)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetSubUnitByName(subUnitName);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting subunit", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="storeID"></param>
        /// <returns></returns>
        public DataSet GetStoreByID(int storeID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetStoreByID(storeID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting store", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="storeName"></param>
        /// <returns></returns>
        public DataSet GetStoreByName(string storeName)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetStoreByName(storeName);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting store", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="storeID"></param>
        /// <param name="subUnitID"></param>
        /// <returns></returns>
        public DataSet GetStoreUnitStatus(int storeID, int subUnitID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetStoreUnitStatus(storeID, subUnitID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting store unit", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetAllStores()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetAllStores();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting stores", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetActiveCentralStores()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetActiveCentralStores();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting active central stores", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetSubUnits()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetSubUnits();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting sub units", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetActiveSubUnits()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetActiveSubUnits();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting active sub units", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetStoreUnits()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetStoreUnits();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting store units", ex);
            }
            return ds;
        }

        /// <summary>
        /// Sean Christensen
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DataSet GetStoresByType(int type)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetStoresByType(type);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting stores by type", ex);
            }
            return ds;
        }

        /// <summary>
        /// Created by Adam Venezia 10-21-12, helps with CEO signoff print off.
        /// </summary>
        /// <param name="rID">Requisition ID passed to stored procedure.</param>
        /// <returns>DataSet with error table on table 0, or desired information on table 1.</returns>
        public DataSet GetRequisitionByRequisitionID(int rID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetRequisitionByRequisitionID(rID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting stores by type", ex);
            }
            return ds;
        }

        #endregion

        //////////Vendor Methods//////////
        // AddVendor
        // ModifyVendor
        // GetVendors
        // GetVendorByID
        // GetActiveVendors
        // AddVendorItem
        /////////////////////////////////
        #region Vendor Methods

        /// <summary>
        /// 
        /// </summary>
        /// <param name="vendorName"></param>
        /// <param name="vendorAddress"></param>
        /// <param name="phone"></param>
        /// <returns></returns>
        public DataSet AddVendor(string vendorName, string vendorAddress, string phone)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                if (!isValidVendorName(vendorName))
                {
                    ds.Tables.Add();
                    ds.Tables[0].Columns.Add();
                    ds.Tables[0].Rows.Add();
                    ds.Tables[0].Rows[0][0] = "Invalid Vendor Name";
                }
                else
                {
                    //if vendor address or phone is null, make them '-1' for the database procedure
                    if (String.IsNullOrEmpty(vendorAddress))
                        vendorAddress = "-1";

                    if (String.IsNullOrEmpty(phone))
                        phone = "-1";

                    ds = dt.AddVendor(vendorName, vendorAddress, phone);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding vendor", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="vendorID"></param>
        /// <param name="vendorName"></param>
        /// <param name="vendorAddress"></param>
        /// <param name="phone"></param>
        /// <param name="statusID"></param>
        /// <returns></returns>
        public DataSet ModifyVendor(int vendorID, string vendorName, string vendorAddress, string phone, int statusID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                if (!isValidVendorName(vendorName))
                {
                    ds.Tables.Add();
                    ds.Tables[0].Columns.Add();
                    ds.Tables[0].Rows.Add();
                    ds.Tables[0].Rows[0][0] = "Invalid Vendor Name";
                }
                else
                {
                    //if vendor address or phone is null, make them '-1' for the database procedure
                    if (String.IsNullOrEmpty(vendorAddress))
                        vendorAddress = "-1";

                    if (String.IsNullOrEmpty(phone))
                        phone = "-1";

                    ds = dt.ModifyVendor(vendorID, vendorName, vendorAddress, phone, statusID);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error modifying vendor", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetVendors()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetVendors();

            }
            catch (Exception ex)
            {
                ds = SetError("Error getting vendors", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="vendorID"></param>
        /// <returns></returns>
        public DataSet GetVendorByID(int vendorID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetVendorByID(vendorID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting vendor", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetActiveVendors()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetActiveVendors();

            }
            catch (Exception ex)
            {
                ds = SetError("Error getting active vendors", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="itemID"></param>
        /// <param name="vendorID"></param>
        /// <param name="vendorCost"></param>
        /// <param name="purDate"></param>
        /// <param name="quantity"></param>
        /// <returns></returns>
        public DataSet AddVendorItem(int itemID, int vendorID, decimal vendorCost, string purDate, int quantity)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                DateTime purchaseDate;
                bool isDate = DateTime.TryParse(purDate, out purchaseDate);
                if (isDate)
                {
                    ds = dt.AddVendorItem(itemID, vendorID, vendorCost, purchaseDate, quantity);
                }
                else
                {
                    ds = SetError("Invalid date", null);
                }
            }
            catch (Exception ex)
            {
                ds = SetError("Error adding vendor item", ex);
            }
            return ds;
        }

        #endregion

        //////////Report Methods//////////
        // GetMonthlyReport
        // GetQuarterlyReport
        // GetYearlyReport
        // ReportCurrentItems
        // ReportCurrentItemByItemID
        // ReportCurrentItemsBySubUnit
        // ReportCurrentItemsByCategory
        // ItemReportForDateRange
        // GetYears
        /////////////////////////////////
        #region Report Methods

        /// <summary>
        /// Gets the report items for a specified month
        /// By Sean Christensen
        /// </summary>
        /// <param name="monthNum"></param>
        /// <param name="year"></param>
        /// <param name="preparedBy"></param>
        /// <returns>DataSet</returns>
        public DataSet GetMonthlyReport(int monthNum, int year, string preparedBy)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                DateTime startDate;
                DateTime endDate;
                string date;
                switch (monthNum)
                {
                    // Formatted for US dateTime format MM/DD/YYYY
                    case 1:
                        date = "01/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "01/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 2:
                        date = "02/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        // Check if the year is a leap year
                        if (System.DateTime.IsLeapYear(year))
                            date = "02/29/" + year.ToString();
                        else
                            date = "02/28/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 3:
                        date = "03/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "03/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 4:
                        date = "04/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "04/30/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 5:
                        date = "05/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "05/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 6:
                        date = "06/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "06/30/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 7:
                        date = "07/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "07/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 8:
                        date = "08/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "08/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 9:
                        date = "09/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "09/30/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 10:
                        date = "10/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "10/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 11:
                        date = "11/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "11/30/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 12:
                        date = "12/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "12/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    // Formatted for Ghana dateTime format YYYY/MM/DD
                    //case 1:
                    //    date = year.ToString() + "/01/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/01/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 2:
                    //    date = year.ToString() + "/02/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    // Check if year is a leap year
                    //    if (System.DateTime.IsLeapYear(year))
                    //        date = year.ToString() + "/02/29";
                    //    else
                    //        date = year.ToString() + "/02/28";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 3:
                    //    date = year.ToString() + "/03/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/03/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 4:
                    //    date = year.ToString() + "/04/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/04/30";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 5:
                    //    date = year.ToString() + "/05/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/05/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 6:
                    //    date = year.ToString() + "/06/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/06/30";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 7:
                    //    date = year.ToString() + "/07/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/07/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 8:
                    //    date = year.ToString() + "/08/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/08/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 9:
                    //    date = year.ToString() + "/09/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/09/30";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 10:
                    //    date = year.ToString() + "/10/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/10/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 11:
                    //    date = year.ToString() + "/11/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/11/30";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 12:
                    //    date = year.ToString() + "/12/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/12/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    default:
                        return ds = SetError("Error getting monthly report", null);
                    //break;
                }
                ds = dt.ReportItemsByDate(startDate, endDate, preparedBy);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting monthly report", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets all items in a quarterly report
        /// By Sean Christensen
        /// </summary>
        /// <param name="quarter"></param>
        /// <param name="year"></param>
        /// <param name="preparedBy"></param>
        /// <returns>DataSet</returns>
        public DataSet GetQuarterlyReport(int quarter, int year, string preparedBy)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                DateTime startDate;
                DateTime endDate;
                string date;
                switch (quarter)
                {
                    // Formatted for US dateTime format MM/DD/YYYY
                    case 1:
                        date = "01/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "03/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 2:
                        date = "04/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "06/30/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 3:
                        date = "07/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "09/30/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    case 4:
                        date = "10/01/" + year.ToString();
                        startDate = Convert.ToDateTime(date);
                        date = "12/31/" + year.ToString();
                        endDate = Convert.ToDateTime(date);
                        break;
                    // Formatted for Ghana dateTime format YYYY/MM/DD
                    //case 1:
                    //    date = year.ToString() + "/01/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/03/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 2:
                    //    date = year.ToString() + "/04/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/06/30";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 3:
                    //    date = year.ToString() + "/07/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/09/30";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    //case 4:
                    //    date = year.ToString() + "/10/01";
                    //    startDate = Convert.ToDateTime(date);
                    //    date = year.ToString() + "/12/31";
                    //    endDate = Convert.ToDateTime(date);
                    //    break;
                    default:
                        return ds = SetError("Error getting quarterly report", null);
                    //break;
                }
                ds = dt.ReportItemsByDate(startDate, endDate, preparedBy);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting quarterly report", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets all items in a yearly report
        /// by Sean Christensen
        /// </summary>
        /// <param name="year"></param>
        /// <param name="preparedBy"></param>
        /// <returns></returns>
        public DataSet GetYearlyReport(int year, string preparedBy)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                DateTime startDate;
                DateTime endDate;
                string date;
                // Formatted for US dateTime format MM/DD/YYYY
                date = "01/01/" + year.ToString();
                startDate = Convert.ToDateTime(date);
                date = "12/31/" + year.ToString();
                endDate = Convert.ToDateTime(date);
                // Formatted for Ghana dateTime format YYYY/MM/DD
                //    date = year.ToString() + "/01/01";
                //    startDate = Convert.ToDateTime(date);
                //    date = year.ToString() + "/12/31";
                //    endDate = Convert.ToDateTime(date);
                ds = dt.ReportItemsByDate(startDate, endDate, preparedBy);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting yearly report", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets all items and their current status
        /// By Sean Christensen
        /// </summary>
        /// <returns></returns>
        public DataSet ReportCurrentItems()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ReportCurrentItems();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting current items report", ex);
            }
            return ds;
        }

        /// <summary>
        /// Gets a report on a specific item
        /// By Sean Christensen
        /// </summary>
        /// <param name="itemID"></param>
        /// <returns></returns>
        public DataSet ReportCurrentItemByItemID(int itemID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ReportCurrentItemByItemID(itemID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting current items by item report", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="subUnitID"></param>
        /// <returns></returns>
        public DataSet ReportCurrentItemsBySubUnit(int subUnitID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ReportCurrentItemsBySubUnit(subUnitID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting current items by subunit report", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="categoryID"></param>
        /// <returns></returns>
        public DataSet ReportCurrentItemsByCategory(int categoryID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.ReportCurrentItemsByCategory(categoryID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting current items by category report", ex);
            }
            return ds;
        }
        /// <summary>
        /// Retrieves the data to be used for an Item Adjustment Report given certain dates.
        /// </summary>
        /// <param name="startDate">the selected start date</param>
        /// <param name="endDate">the selected end date</param>
        /// <returns>a table of the information to populate a report</returns>
        public DataSet ReportItemAdjustments(DateTime startDate, DateTime endDate)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();

            try
            {
                ds = dt.ReportItemAdjustments(startDate, endDate);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting item report for a specific date range, please verify date(s) are valid.", ex);
            }
            return ds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetYears()
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetYears();
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting years list", ex);
            }
            return ds;
        }

        #endregion

        //////////Validation Methods//////////
        // isValidPW
        // isValidUserName
        // isValidHint
        // isValidFirstName
        // isValidSurName
        // isValidItemCategory
        // isValidVendorName
        // isValidRoleSelection
        /////////////////////////////////
        #region Validation

        /// <summary>
        /// Method checks if user password contains 6 or more characters no
        /// spaces, at least one digit or non-word character, and at least one word character.
        /// Written by Sean Christensen
        /// </summary>
        /// <param name="password"></param>
        /// <returns>True if valid, false if invalid</returns>
        public Boolean isValidPW(string password)
        {
            Boolean results = false;
            Regex hasDigitOrSpecial = new Regex(@"[\d\W]");
            Regex hasAlpha = new Regex(@"[\w]");
            //string strRegex = @"(?=.*[\d\W])";
            //Regex re = new Regex(strRegex);
            if (password.Length >= 6 && password.Length <= 20 && !password.Contains(" ") && hasDigitOrSpecial.IsMatch(password) && hasAlpha.IsMatch(password))
                results = true;
            return results;
        }

        /// <summary>
        /// Method checks if the username contains 4-10 characters and is 
        /// only alphanumeric characters
        /// Written by Sean Christensen
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>True if valid, false if invalid</returns>
        public Boolean isValidUserName(string userName)
        {
            Boolean results = false;
            string strRegex = @"[a-zA-Z0-9]{4,20}$";
            Regex re = new Regex(strRegex);
            if (!userName.Contains(" ") && re.IsMatch(userName))
                results = true;
            return results;
        }

        /// <summary>
        /// Checks if password hint contains 4-100 characters and is
        /// only alphanumeric
        /// Written by Sean Christensen
        /// </summary>
        /// <param name="passwordHint"></param>
        /// <returns>True if valid, false if invalid</returns>
        public Boolean isValidHint(string passwordHint)
        {
            Boolean results = false;
            string strRegex = @"[a-zA-Z0-9]{4,100}$";
            Regex re = new Regex(strRegex);
            if (!string.IsNullOrEmpty(passwordHint) && re.IsMatch(passwordHint))
                results = true;
            return results;
        }

        /// <summary>
        /// Checks if first name contains 1-20 characters and is
        /// only alpha characters.
        /// Written by Sean Christensen
        /// </summary>
        /// <param name="firstName"></param>
        /// <returns>True if valid, false if invalid</returns>
        public Boolean isValidFirstName(string firstName)
        {
            Boolean results = false;
            string strRegex = @"[a-zA-Z]{1,20}$";
            Regex re = new Regex(strRegex);
            if (!string.IsNullOrEmpty(firstName) && re.IsMatch(firstName))
                results = true;
            return results;
        }

        /// <summary>
        /// Checks if sir name contains 1-20 characters and is
        /// only alpha characters.
        /// Written by Sean Christensen
        /// </summary>
        /// <param name="sirName"></param>
        /// <returns>True if valid, false if invalid</returns>
        public Boolean isValidSurName(string sirName)
        {
            Boolean results = false;
            string strRegex = @"[a-zA-Z]{2,20}$";
            Regex re = new Regex(strRegex);
            if (!string.IsNullOrEmpty(sirName) && re.IsMatch(sirName))
                results = true;
            return results;
        }

        /// <summary>
        /// Checks if item names or category names contain more than 30 characters and is
        /// null.
        /// Written by Sean Christensen
        /// </summary>
        /// <param name="itemCategory"></param>
        /// <returns>True if valid, false if invalid</returns>
        public Boolean isValidItemCategory(string itemCategory)
        {
            bool results = true;
            if (string.IsNullOrEmpty(itemCategory) || itemCategory.Length > 30)
            {
                results = false;
            }
            return results;
        }

        /// <summary>
        /// Checks to see if the vendor name is null or 30 chars long.
        /// Written by Sean Christensen
        /// </summary>
        /// <param name="vendorName"></param>
        /// <returns>True if valid, false if invalid</returns>
        public Boolean isValidVendorName(string vendorName)
        {
            bool results = true;
            if (string.IsNullOrEmpty(vendorName) || vendorName.Length > 30)
            {
                results = false;
            }
            return results;
        }

        /// <summary>
        /// Checks to see if more than one of these roles is true.
        /// </summary>
        /// <param name="isGeneralManager"></param>
        /// <param name="isStoreManager"></param>
        /// <param name="isSubUnitClerk"></param>
        /// <param name="isCEO"></param>
        /// <returns></returns>
        public Boolean isValidRoleSelection(bool isGeneralManager, bool isStoreManager, bool isSubUnitClerk, bool isCEO)
        {
            bool results = true;
            if (isGeneralManager)
            {
                if (isStoreManager || isSubUnitClerk || isCEO)
                    results = false;
            }
            else if (isStoreManager)
            {
                if (isGeneralManager || isSubUnitClerk || isCEO)
                    results = false;
            }
            else if (isSubUnitClerk)
            {
                if (isGeneralManager || isStoreManager || isCEO)
                    results = false;
            }
            else if (isCEO)
            {
                if (isGeneralManager || isStoreManager || isSubUnitClerk)
                    results = false;
            }
            return results;
        }

        #endregion

        //////////Log Methods//////////
        // UpdateItemQuantityReceived
        // CompleteRequisition
        // UpdateLPO
        // UpdateSRA
        // GetReceiptVoucher
        /////////////////////////////////
        #region Log Methods

        /// <summary>
        /// Bryan Nixon
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <param name="itemID"></param>
        /// <param name="quantity"></param>
        /// <returns></returns>
        public DataSet UpdateItemQuantityReceived(int requisitionID, int itemID, int quantity, int vendorID, int LPO, String recOfficer)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.UpdateItemQuantityReceived(requisitionID, itemID, quantity, vendorID, LPO, recOfficer);
            }
            catch (Exception ex)
            {
                ds = SetError("Error item quantity received", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Bryan Nixon
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <returns></returns>
        public DataSet CompleteRequisition(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.CompleteRequisition(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error completing requisition", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <param name="lpo"></param>
        /// <returns></returns>
        public DataSet UpdateLPO(int requisitionID, string lpo)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.UpdateLPO(requisitionID, lpo);
            }
            catch (Exception ex)
            {
                ds = SetError("Error updating LPO", ex);
            }
            return ds;
        }

        /// <summary>
        /// Bryan Nixon
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <returns></returns>
        public DataSet GetLPO(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetLPO(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error retrieving LPO", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <param name="sraNo"></param>
        /// <param name="sra"></param>
        /// <returns></returns>
        public DataSet UpdateSRA(int requisitionID, int sraNo, string sra)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.UpdateSRA(requisitionID, sraNo, sra);
            }
            catch (Exception ex)
            {
                ds = SetError("Error updating SRA", ex);
            }
            return ds;
        }

        /// <summary>
        /// Bryan Nixon
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <returns></returns>
        public DataSet GetSRA(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetSRA(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error retrieving LPO", ex);
            }
            return ds;
        }

        /// <summary>
        /// By Sean Christensen
        /// </summary>
        /// <param name="requisitionID"></param>
        /// <returns></returns>
        public DataSet GetReceiptVoucher(int requisitionID)
        {
            DataSet ds = new DataSet();
            DataTier dt = new DataTier();
            try
            {
                ds = dt.GetReceiptVoucher(requisitionID);
            }
            catch (Exception ex)
            {
                ds = SetError("Error getting receipt voucher", ex);
            }
            return ds;
        }

        #endregion

        //////////Error Methods//////////
        // SetError
        /////////////////////////////////
        #region Error Handling

        /// <summary>
        /// If there is an error thrown, the exception or error message will be returned.
        /// Written by Sean Christensen
        /// </summary>
        /// <param name="ErrorMessage"></param>
        /// <param name="ex"></param>
        /// <returns>DataSet containing the error in Tables[0].Rows[0][0]</returns>
        //Modified by Adam Venezia 10-16-12; table was being built wrong and throwing an exception itself.
        public DataSet SetError(String ErrorMessage, Exception ex)
        {
            try
            {
                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                dt.Columns.Add();
                DataRow dr = dt.NewRow();

                if (ErrorMessage != null)
                {
                    dr[0] = ErrorMessage;
                }
                else
                {
                    dr[0] = ex;
                }

                dt.Rows.Add(dr);
                ds.Tables.Add(dt);

                return ds;
            }
            catch
            {
                DataSet ds = new DataSet();
                return ds;
            }
        }

        #endregion
    }
}